#!/bin/sh
# postrm script for penguins-eggs_9.7.8-1
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see https://www.debian.org/doc/debian-policy/ or
# the debian-policy package

#echo ">>> $0 $1 $2 $3 $4<<<"


case "$1" in
    purge)
        # eggs configurazione
        rm -rf /etc/penguins-eggs.d/

        # calamares config
        rm -rf /etc/calamares/
    ;;

    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        # scripts
        rm -f /usr/bin/adapt
        rm -f /usr/bin/love
        rm -f /usr/sbin/resy

        # sanitize /usr/lib/penguins-eggs/
        rm -rf /usr/lib/penguins-eggs/distros
        rm -rf /usr/lib/penguins-eggs/eui
        rm -rf /usr/lib/penguins-eggs/krill

        # sanitize applications links
        rm -f /usr/share/applications/penguins-adapt.desktop
        rm -f /usr/share/applications/penguins-clinstaller.desktop
        rm -f /usr/share/applications/penguins-eggs.desktop

        # sanitize xdg links
        rm -f /etc/xdg/autostart/penguins-links-add.desktop
        rm -f /usr/bin/penguins-links-add.sh
        
        # sanitize others
        rm -f /usr/bin/pve-live.sh
        rm -f /etc/systemd/system/pve-live.service

        # sanitize bash completion
        rm -f /usr/share/bash-completion/completions/eggs.bash
        rm -f /usr/share/zsh/functions/Completion/Zsh/_eggs

        # sanitize yolk
        rm -rf /var/local/yolk

        # sanitize penguins-eggs multiarch (krill-modules)
        rm -rf /usr/lib/i386-linux-gnu/penguins-eggs/
        rm -rf /usr/lib/x86_64-linux-gnu/penguins-eggs/
        # armel and arm64 have all in /usr/lib/penguins-eggs/
        # so don't need to be removed
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
